﻿using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using TSVNAddin.SVN;
using System.IO;

namespace TSVNAddin.Core
{
	public class ProjectActionExecutor : IProjectEventListener
	{
		private readonly ProjectAddedAction _AddedAction;
		private readonly PathRemovedAction _RemovedAction;
		private readonly PathRenamedAction _RenamedAction;

		public ProjectActionExecutor(
			ProjectAddedAction addedAction,
			PathRemovedAction removedAction,
			PathRenamedAction renamedAction)
		{
			_AddedAction = addedAction;
			_RemovedAction = removedAction;
			_RenamedAction = renamedAction;
		}

		public void NotifyAdded(Project project)
		{
			_AddedAction.Execute(project);
		}

		public void NotifyRemoved(Project project)
		{
			string directory = Path.GetDirectoryName(project.FullName);
			_RemovedAction.Execute(directory);
		}

		public void NotifyRenamed(Project project, string oldName)
		{
			_RenamedAction.Execute(project.FullName, oldName);
		}
	}
}